﻿using System;
using System.Web.Mail;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using MLY;
using MLY.Dal;
using MLY.Bll;
using System.IO;

namespace MLY.Reports.SCCoverReports
{
    public partial class LastOrderReport : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ExportToExcel(object sender, EventArgs e)
        {
            MLY.Bll.ExcelExport.PrepareCsvFileFromGridview(ReportGridview, "LastOrdersReport");
        }
        protected void GenerateReport(object sender, EventArgs e)
        {
            ReportDataSource.SelectParameters.Clear();
            if (txtFromDate.Text.Length > 0)
            {
               ReportDataSource.SelectParameters.Add("StartDate",  MLY.Utils.SqlDate(DateTime.Parse(txtFromDate.Text.Trim())));
            }
            if (txtToDate.Text.Length > 0)
            {
                ReportDataSource.SelectParameters.Add("EndDate", MLY.Utils.SqlDate(DateTime.Parse(txtToDate.Text.Trim())));
            }
            ReportDataSource.SelectParameters.Add("Open", OpenClosedRBL.SelectedValue);
            ReportDataSource.SelectParameters.Add("OrgId", SessParam.OrganizationId.ToString());
            ReportPanel.Visible = true;
            ReportGridview.DataSourceID = "ReportDataSource";
            ReportDataSource.DataBind();
            ReportGridview.DataBind();
        }

        protected void ClearDates(object sender, EventArgs e)
        {
            txtFromDate.Text = "";
            txtToDate.Text = "";
        }
    }
}
